package relation;

import cn.moukou.dictator.ServerApplication;
import cn.moukou.dictator.dao.node.KVNodeDAO;
import cn.moukou.dictator.dao.relation.KVNODE_RELATION_DAO;
import cn.moukou.dictator.dao.relation.STUDENT_AWARD_DAO;
import cn.moukou.dictator.dao.relation.STUDENT_CLASS_DAO;
import cn.moukou.dictator.pojo.node.KVNode;
import cn.moukou.dictator.pojo.relation.KVNODE_RELATION;
import cn.moukou.dictator.pojo.relation.STUDENT_AWARD;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

import java.util.ArrayList;
import java.util.List;

@SpringBootTest(classes = ServerApplication.class)
public class STUDENT_AWARD_TEST {
    @Autowired
    STUDENT_AWARD_DAO relationDao;
    @Autowired
    KVNODE_RELATION_DAO kvRelationDao;
    @Autowired
    KVNodeDAO kvDao;

    @Test
    public void addRelation() {
        KVNode start = kvDao.customFindByStudentName("冯璐");
        List<String> namaList = new ArrayList<>();
//        namaList.add("省级三好学生");
//        namaList.add("市优秀团员");
        namaList.add("省级优秀学生干部");
        namaList.add("市三好学生");

        for(int i = 0; i < namaList.size(); ++i) {
            KVNode end = kvDao.customFindByAwardName(namaList.get(i));
            STUDENT_AWARD relation = new STUDENT_AWARD();
            relation.setStartNode(start);
            relation.setEndNode(end);
            relationDao.save(relation);
        }
    }

    @Test
    public void addKVNODE_RELATION() {
        Iterable<STUDENT_AWARD> it = relationDao.findAll();
        for (STUDENT_AWARD st_aw : it) {
            System.out.println(st_aw);
            KVNODE_RELATION kvRelation = new KVNODE_RELATION();
            kvRelation.setStartNode(st_aw.getStartNode());
            kvRelation.setEndNode(st_aw.getEndNode());
            kvRelation.setRelationType("student_award");
            kvRelation.setRelationLabel("st_aw");
            kvRelationDao.save(kvRelation);
        }
    }
}
